// function createPhoneNumber (nums) {

//     return '(' + nums[0] + nums[1] + nums[2] + ') ' +     
//         nums[3] + nums[4] + nums[5] + '-' + nums[6] +
//         nums[7] + nums[8] + nums[9];
// }
// (123) 465-7890


const createPhoneNumber = (nums) => {
    let format = '(xxx) xxx-xxxx';
    for(i = 0;i < nums.length;i++){
        format = format.replace('x',nums[i]);
    }
    return format;
}

console.log(createPhoneNumber([1,2,3,4,5,6,7,8,9,0]));